package com.feonix.complat.constant;

import java.io.File;

import com.feonix.common.BaseInfo;
import com.feonix.common.util.FileUtil;
import com.feonix.common.util.SpringUtil;
import com.feonix.common.util.StringUtil;


/**
 * 系统参数
 * 
 * 
 */
public class Settings {

	/**
	 * 密码强度等级
	 */
	private int checkLevel = 2;

	/**
	 * 验证码
	 */
	private boolean enableVerifyCode = true;

	/**
	 * 权限拦截模式
	 */
	private int interceptMode = 1;

	/**
	 * 是否开启意见反馈
	 */
	private boolean canFeedback = false;

	/**
	 * 登录错误次数
	 */
	private int loginError = 3;

	/**
	 * 登录错误的封停时间
	 */
	private int banTimes = 15;

	/**
	 * 登录超时时间
	 */
	private int sessionTime = 30;

	/**
	 * 文件暂存目录
	 */
	private String fileTmp;

	/**
	 * 高级编辑器上传的图片路径
	 */
	private String imageDir;

	/**
	 * 高级编辑器上传的附件路径
	 */
	private String attachmentDir;
	
	/**
	 * 版权信息
	 */
	private String copyRight;

	public int getCheckLevel() {
		return checkLevel;
	}

	public void setCheckLevel(int checkLevel) {
		this.checkLevel = checkLevel;
	}

	public boolean isEnableVerifyCode() {
		return enableVerifyCode;
	}

	public void setEnableVerifyCode(boolean enableVerifyCode) {
		this.enableVerifyCode = enableVerifyCode;
	}

	public int getInterceptMode() {
		return interceptMode;
	}

	public void setInterceptMode(int interceptMode) {
		this.interceptMode = interceptMode;
	}

	public boolean isCanFeedback() {
		return canFeedback;
	}

	public void setCanFeedback(boolean canFeedback) {
		this.canFeedback = canFeedback;
	}

	public int getLoginError() {
		return loginError;
	}

	public void setLoginError(int loginError) {
		this.loginError = loginError;
	}

	public int getBanTimes() {
		return banTimes;
	}

	public void setBanTimes(int banTimes) {
		this.banTimes = banTimes;
	}

	public int getSessionTime() {
		return sessionTime;
	}

	public void setSessionTime(int sessionTime) {
		this.sessionTime = sessionTime;
	}

	public String getFileTmp() {
		if (StringUtil.isEmpty(fileTmp)) {
			fileTmp = BaseInfo.getRealPath() + "/tempfile/";
		}
		File file = new File(fileTmp);
		FileUtil.isDirExsit(file, true);
		return StringUtil.convertPath(fileTmp, true);
	}

	public void setFileTmp(String fileTmp) {
		this.fileTmp = fileTmp;
	}

	/**
	 * 获得系统Setting对象
	 * 
	 * @return
	 */
	public static Settings getSettings() {
		return SpringUtil.getBean("complat_Settings", Settings.class);
	}

	/**
	 * 获得高级编辑器上传的图片路径
	 * 
	 * @return
	 */
	public String getImageDir() {
		if (StringUtil.isEmpty(imageDir)) {
			this.imageDir = BaseInfo.getRealPath() + "/upload/images/";
		}
		File file = new File(this.imageDir);
		FileUtil.isDirExsit(file, true);
		return StringUtil.convertPath(this.imageDir, true);
	}

	/**
	 * 获得高级编辑器上传的附件路径
	 * 
	 * @return
	 */
	public String getAttachmentDir() {
		if (StringUtil.isEmpty(attachmentDir)) {
			this.attachmentDir = BaseInfo.getRealPath() + "/upload/attachment/";
		}
		File file = new File(this.attachmentDir);
		FileUtil.isDirExsit(file, true);
		return StringUtil.convertPath(this.attachmentDir, true);
	}

	public void setImageDir(String imageDir) {
		this.imageDir = imageDir;
	}

	public void setAttachmentDir(String attachmentDir) {
		this.attachmentDir = attachmentDir;
	}

	public String getCopyRight() {
		return copyRight;
	}

	public void setCopyRight(String copyRight) {
		this.copyRight = copyRight;
	}
	
}
